import $ from "jquery";
$.ajaxSetup({
  async: false,
  dataType: "JSON",
  type: "post",
});

/* @return <Promise> resolve 返回的数据 */
function resolveData(fakeData) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve(fakeData);
    }, 500);
  });
}

export default {
  searchBeauticianOrders({
    uid,
    rows,
    page
  }) {
    return resolveData({
      total: 100,
      rows: [{
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
          arriveRate: .5
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
        {
          id: "123",
          tid: "456",
          tname: "项目1",
          uid: "123",
          name: "林悦",
          balance: "3000",
          starttime: 1230093565,
          endtime: 1230093565,
          time: "3",
        },
      ],
    });
  },
  fillUserRemarks({
    uid,
    remarks
  }) {
    return resolveData({
      result: true,
      message: "成功",
    });
  },

  upReport({
    rids
  }) {
    return resolveData({
      result: true,
      message: "成功",
    });
  },
  searchStocks({
    uid,
    rows,
    page
  }) {
    return resolveData({
      total: 2,
      rows: [{
          id: "123",
          pid: "123",
          pname: "项目1",
          count: 10,
          numSpec: 3,
          spec: "瓶",
          useSpec: 5,
          surplusSpec: 5,
        },
        {
          id: "123",
          pid: "123",
          pname: "项目1",
          count: 10,
          numSpec: 3,
          spec: "瓶",
          useSpec: 5,
          surplusSpec: 5,
        },
      ],
    });
  },
  searchStaffStocks({
    pid,
    fid,
    rows,
    page
  }) {
    return resolveData({
      total: 1,
      rows: [{
        pname: '项目1',
        count: 100,
        pSpec: 'ml',
        numSpec: 4,
        spec: 'ml',
        createtime: 1213345556,
      }],
    });
  },
  /* 打卡 */
  checkWork({
    uid,
    code
  }) {
    return resolveData({
      total: 2,
      rows: [{
          id: "123",
          pid: "123",
          pname: "项目1",
          count: 10,
          numSpec: 3,
          spec: "瓶",
          useSpec: 5,
          surplusSpec: 5,
        },
        {
          id: "123",
          pid: "123",
          pname: "项目1",
          count: 10,
          numSpec: 3,
          spec: "瓶",
          useSpec: 5,
          surplusSpec: 5,
        },
      ],
    });
  },
  /* 用户端 */
  userHomeInfo({
    uid
  }) {
    return resolveData({
      amount: 100000,
      balance: 80000,
      items: [{
          tid: "123",
          tname: "项目1",
        },
        {
          tid: "124",
          tname: "项目2",
        },
        {
          tid: "125",
          tname: "项目3",
        },
        {
          tid: "126",
          tname: "项目4",
        },
      ],
      products: [{
          pid: "123",
          pname: "产品1",
        },
        {
          pid: "124",
          pname: "产品2",
        },
        {
          pid: "125",
          pname: "产品3",
        },
        {
          pid: "126",
          pname: "产品4",
        },
      ],
    });
  },
  getStoreItems({
    sid
  }) {
    return resolveData([{
        tid: "123",
        tname: "项目一",
        imgurl: "",
        time: 30,
      },
      {
        tid: "123",
        tname: "项目一",
        imgurl: "",
        time: 30,
      },
    ]);
  },
  searchStores({
    pid,
    cid
  }) {
    return resolveData([{
      sid: "123",
      sname: "门店一",
      starttime: "9:00",
      endtime: "20:00",
      time: 1023234,
    }, ]);
  },
  getProCities() {
    return resolveData(
      [{
          id: '123',
          text: '辽宁省',
          children: [{
              id: '1234',
              text: '沈阳市',
            },
            {
              id: '1234',
              text: '朝阳市',
            },
          ]
        },
        {
          id: '124',
          text: '吉林省',
          children: [{
            id: '1234',
            text: '长春市',
          }, ]
        },
      ]
    )
  },
  loadUserRemarks() {
    return resolveData({
      specials: [{
        name: '名称1',
        type: 0,
        infos: ['选项1', '选项2', '选项3']
      }, {
        name: '名称2',
        type: 1,
        infos: ['选项1', '选项2', '选项3']
      }]
    })
  },
  completeOrder() {
    return resolveData({
      result: true,
      message: '成功'
    })
  },
  dayReports({
    fid
  }) {
    return resolveData({
      totalAmount: 10000000,
      totalCommission: 2000000,
      infos: [{
        id: '123',
        pid: '123213',
        pname: '项目1',
        uid: '123',
        name: '张三',
        discount: 4.5,
        consume: 3,
        proportion: .3,
        commission: 1000,
        payTime: 1224454323
      }]
    })
  },
  monthReports({
    fid
  }) {
    return resolveData({
      totalAmount: 10000000,
      totalCommission: 2000000,
      infos: [{
        id: '123',
        pid: '123213',
        pname: '项目1',
        uid: '123',
        name: '张三',
        discount: 4.5,
        consume: 3,
        proportion: .3,
        commission: 1000,
        payTime: 1224454323
      }]
    })
  }
};